package com.zzy.chapter4.template;

import java.util.Date;

public abstract class AbstractAuditLogProcessor {

    private final OrderAuditLog basicAuditLog(String account, String action, String orderId) {
        OrderAuditLog auditLog = new OrderAuditLog();
        auditLog.setAccount(account);
        auditLog.setAction(action);
        auditLog.setDate(new Date());
        auditLog.setOrderId(orderId);
        return auditLog;
    }

    protected abstract OrderAuditLog buildDetails(OrderAuditLog orderAuditLog);

    public final OrderAuditLog createAuditLog(String account, String action, String orderId) {
        OrderAuditLog auditLog = basicAuditLog(account, action, orderId);
        return buildDetails(auditLog);
    }
}
